package domain

// Article 制作库帖子
type Article struct {
	Id      int64  `json:"id"`
	Title   string `json:"title"`
	Content string `json:"content"`
	Author  Author
	Ctime   int64 `json:"ctime"`
	Utime   int64 `json:"utime"`
}

// PublishArticle 线上库帖子
type PublishArticle struct {
	Id      int64  `json:"id"`
	Title   string `json:"title"`
	Content string `json:"content"`
	Author  Author
	Ctime   int64 `json:"ctime"`
	Utime   int64 `json:"utime"`
}

func (a *Article) GenerateAbstract() string {
	const MaxLength = 100
	runes := []rune(a.Content)
	return string(runes[:min(MaxLength, len(runes))])
}

type Author struct {
	Id   int64  `json:"id"`
	Name string `json:"name"`
}
